package com.shahe.GirlsDay.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Switch;

import com.shahe.GirlsDay.LogActivity;
import com.shahe.GirlsDay.R;
//import com.example.fragmenttabhosttest.R;

public class SymptomFragment extends Fragment {

	private Switch switchAcne;
	private Switch switchCramps;
	private Switch switchHeadaches;
	private Switch switchBackaches;
	private Switch switchBloating;
	private Switch switchBodyaches;
	private Switch switchNausea;
	private Switch switchNeckaches;
	private Switch switchTB;
	private Switch switchSpotting;
	private Switch switchPP;;
	private Switch switchDizziness;
	private Switch switchCold;
	private Switch switchSleepless;
	private Switch switchFlatulence;
	private Switch switchDiarrhea;
	private Switch switchConstipation;
	private Switch switchFever;

	@Override
	public void onAttach(Activity activity) {
		// TODO Auto-generated method stub
		super.onAttach(activity);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.log_symptom, null);

		switchAcne = (Switch) view.findViewById(R.id.log_sy_switchAcne);
		if (LogActivity.oneDayInfo.getAcne().equals("1")) {
			switchAcne.setChecked(true);
		}
		switchAcne.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setAcne("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setAcne("0");
				}
			}

		});

		switchCramps = (Switch) view.findViewById(R.id.log_sy_switchCramps);
		if (LogActivity.oneDayInfo.getCramps().equals("1")) {
			switchCramps.setChecked(true);
		}
		switchCramps.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setCramps("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setCramps("0");
				}
			}

		});

		switchHeadaches = (Switch) view
				.findViewById(R.id.log_sy_switchHeadaches);
		if (LogActivity.oneDayInfo.getHeadaches().equals("1")) {
			switchHeadaches.setChecked(true);
		}
		switchHeadaches.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setHeadaches("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setHeadaches("0");
				}
			}

		});

		
		
		switchBackaches = (Switch) view
				.findViewById(R.id.log_sy_switchBackaches);
		if (LogActivity.oneDayInfo.getBackaches().equals("1")) {
			switchBackaches.setChecked(true);
		}
		switchBackaches.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setBackaches("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setBackaches("0");
				}
			}

		});

		
		
		switchBloating = (Switch) view.findViewById(R.id.log_sy_switchBloating);

		if (LogActivity.oneDayInfo.getBloating().equals("1")) {
			switchBloating.setChecked(true);
		}
		switchBloating.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setBloating("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setBloating("0");
				}
			}

		});

		
		switchBodyaches = (Switch) view
				.findViewById(R.id.log_sy_switchBodyaches);
		if (LogActivity.oneDayInfo.getBodyaches().equals("1")) {
			switchBodyaches.setChecked(true);
		}
		switchBodyaches.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setBodyaches("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setBodyaches("0");
				}
			}

		});

		
		
		switchNausea = (Switch) view.findViewById(R.id.log_sy_switchNausea);

		if (LogActivity.oneDayInfo.getNausea().equals("1")) {
			switchNausea.setChecked(true);
		}
		switchNausea.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setNausea("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setNausea("0");
				}
			}

		});

		
		switchNeckaches = (Switch) view
				.findViewById(R.id.log_sy_switchNeckaches);

		if (LogActivity.oneDayInfo.getNeckaches().equals("1")) {
			switchNeckaches.setChecked(true);
		}
		switchNeckaches.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setNeckaches("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setNeckaches("0");
				}
			}

		});

		
		switchTB = (Switch) view.findViewById(R.id.log_sy_switchTB);

		if (LogActivity.oneDayInfo.getTenderBreasts().equals("1")) {
			switchTB.setChecked(true);
		}
		switchTB.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setTenderBreasts("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setTenderBreasts("0");
				}
			}

		});

		
		switchSpotting = (Switch) view.findViewById(R.id.log_sy_switchSpotting);

		if (LogActivity.oneDayInfo.getSpotting().equals("1")) {
			switchSpotting.setChecked(true);
		}
		switchSpotting.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setSpotting("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setSpotting("0");
				}
			}

		});

		
		switchPP = (Switch) view.findViewById(R.id.log_sy_switchPP);
		if (LogActivity.oneDayInfo.getPeriodPain().equals("1")) {
			switchPP.setChecked(true);
		}
		switchPP.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setPeriodPain("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setPeriodPain("0");
				}
			}

		});

		
		switchDizziness = (Switch) view
				.findViewById(R.id.log_sy_switchDizziness);
		if (LogActivity.oneDayInfo.getDizziness().equals("1")) {
			switchDizziness.setChecked(true);
		}
		switchDizziness.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setDizziness("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setDizziness("0");
				}
			}

		});

		
		switchCold = (Switch) view.findViewById(R.id.log_sy_switchCold);

		if (LogActivity.oneDayInfo.getCold().equals("1")) {
			switchCold.setChecked(true);
		}
		switchCold.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setCold("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setCold("0");
				}
			}

		});

		switchSleepless = (Switch) view
				.findViewById(R.id.log_sy_switchSleepless);
		if (LogActivity.oneDayInfo.getSleepless().equals("1")) {
			switchSleepless.setChecked(true);
		}
		switchSleepless.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setSleepless("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setSleepless("0");
				}
			}

		});

		switchFlatulence = (Switch) view
				.findViewById(R.id.log_sy_switchFlatulence);
		if (LogActivity.oneDayInfo.getFlatulence().equals("1")) {
			switchFlatulence.setChecked(true);
		}
		switchFlatulence.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setFlatulence("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setFlatulence("0");
				}
			}

		});

		
		switchDiarrhea = (Switch) view.findViewById(R.id.log_sy_switchDiarrhea);
		if (LogActivity.oneDayInfo.getDiarrhea().equals("1")) {
			switchDiarrhea.setChecked(true);
		}
		switchDiarrhea.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setDiarrhea("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setDiarrhea("0");
				}
			}

		});

		
		switchConstipation = (Switch) view
				.findViewById(R.id.log_sy_switchConstipation);
		if (LogActivity.oneDayInfo.getConstipation().equals("1")) {
			switchConstipation.setChecked(true);
		}
		switchConstipation.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setConstipation("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setConstipation("0");
				}
			}
		});

		
		
		switchFever = (Switch) view.findViewById(R.id.log_sy_switchFever);
		if (LogActivity.oneDayInfo.getFever().equals("1")) {
			switchFever.setChecked(true);
		}
		switchFever.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if (isChecked) {
					// Toast.makeText(getActivity(), "True"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setFever("1");

				} else {
					// Toast.makeText(getActivity(), "False"
					// ,Toast.LENGTH_SHORT).show();
					LogActivity.oneDayInfo.setFever("0");
				}
			}
		});
        return view;
    }
}
